package com.fs.alert.controller;

import com.fs.alert.service.IAlertRobotService;
import com.fs.common.domain.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@Api(tags = "警情-机器人相关接口")
@RestController
@RequestMapping("/alert-robot")
@RequiredArgsConstructor
@Slf4j
public class AlertRobotController {
    private final IAlertRobotService alertRobotService;

    @ApiOperation("获取机器人负责的alertId")
    @GetMapping("/robot/{robotId}")
    public Result getAlertIdsByRobotId(@PathVariable("robotId") Long robotId) {
        List<Long> res = new ArrayList<>();
        alertRobotService.list().forEach(alertRobot -> {
            if (alertRobot.getRobotId().equals(robotId)) {
                res.add(alertRobot.getAlertId());
            }
        });
        return Result.ok(res);
    }

}
